<template>
	<view class="">
		<view style="width: 750rpx; background: linear-gradient(180deg,#5A53CE, #5A53CE);min-height: 100vh;display: inline-block;">
			
			<list :list="list" @go='go' ></list>
			
			
			
			<u-loadmore :status="initial.status"  color="#fff"/>
		</view>
		
		
		
		
	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	import wxLocation from '@/common/location.js';
	import list from './components/list.vue'
	export default{
		mixins: [loader],
		components:{
			list
		},
		data(){
			return{
				list:[],
				initial: {
					geturl: "/index/store",
					parm: {
						lat:0,
						lng:0
					},
					limit:5,
					isPage: true
				},
				isCharge:"",
				isBack:false
			}
		},
		onLoad(options) {
			if(options.isCharge){
				this.isCharge=options.isCharge
			}
			if(options.isBack){
				this.isBack=options.isBack
			}
			
			if(!this.$store.state.userAddress){
				const wx=new wxLocation();
				wx.getAddress().then(res=>{
					this.initial.parm.lat=res.result.location.lat;
					this.initial.parm.lng=res.result.location.lng;
					this.getGoods();
				}).catch(err=>{
				
				})
			}else{
				console.log(1111)
				this.initial.parm.lat=this.$store.state.userAddress.result.location.lat;
				this.initial.parm.lng=this.$store.state.userAddress.result.location.lng;
				this.getGoods();
			}
		
			
		},
		methods:{
			
			go(e){
				if(this.isBack){
				   let pages = getCurrentPages(); //获取所有页面栈实例列表
				   let prevPage = pages[pages.length - 2]; //上一页页面实例
				   if (prevPage.route == "pages/my/getCoupond") {
				       prevPage.$vm.store_detail = e;
		
					uni.navigateBack({
						delta: 1
					})
				   }
				   return			   
				}	
				
				if(this.isCharge==1){
					
					return uni.navigateTo({
						url:'/pages/my/charge?id='+e.id
					})
					
				}if(this.isCharge==2){
					return uni.navigateTo({
						url:'/pages/my/storeCard?id='+e.id
					})
				}else{
				return	 uni.navigateTo({
						url:'/pages/store/detail?id='+e.id
					})
				}
				
			}
		}
	}
</script>

<style>
</style>